package com.swiftride.autoconfigure;

import com.swiftride.properties.AppWeChatProperties;
import com.swiftride.template.AppWeChatTemplate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties({AppWeChatProperties.class})
public class WeChatAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean(
            name = {"appWeChatTemplate"}
    )
    public AppWeChatTemplate appWeChatTemplate(AppWeChatProperties appWeChatProperties) {
        AppWeChatTemplate appWeChatTemplate = new AppWeChatTemplate(appWeChatProperties);
        return appWeChatTemplate;
    }
}
